#ifndef _IOT_BOARD_SENSOR_H_
#define _IOT_BOARD_SENSOR_H_
#include "tuya_comm.h"

#define UI_EVENT_LINE_CONT 18

typedef enum
{
  POWER_OFF_CMD = 0x00, //断电：无激活状态
  POWER_ON_CMD  = 0x01, //通电：等待测量指令
  RESET_REGISTER  = 0x07, //重置数字寄存器（在断电状态下不起作用）
  CONT_H_MODE   = 0x10, //连续H分辨率模式：在11x分辨率下开始测量，测量时间120ms
  CONT_H_MODE2  = 0x11, //连续H分辨率模式2：在0.51x分辨率下开始测量，测量时间120ms
  CONT_L_MODE   = 0x13, //连续L分辨率模式：在411分辨率下开始测量，测量时间16ms
  ONCE_H_MODE   = 0x20, //一次高分辨率模式：在11x分辨率下开始测量，测量时间120ms，测量后自动设置为断电模式
  ONCE_H_MODE2  = 0x21, //一次高分辨率模式2：在0.51x分辨率下开始测量，测量时间120ms，测量后自动设置为断电模式
  ONCE_L_MODE   = 0x23  //一次低分辨率模式：在411x分辨率下开始测量，测量时间16ms，测量后自动设置为断电模式
} BH1750_MODE;


typedef enum {
    // 100+ 为OTA事件
    IOT_OTA_EVENT_DOWNLOAD_START = 100,
    IOT_OTA_EVENT_DOWNLOAD_COMPLETE,
    IOT_OTA_EVENT_DONWLOAD_FAIL,
    IOT_OTA_EVENT_UPDATE_START,
    IOT_OTA_EVENT_UPDATE_SUCCESS,
    IOT_OTA_EVENT_UPDATE_FAIL,
    IOT_OTA_EVENT_SCHEMA_DONWLOAD_START,
    IOT_OTA_EVENT_SCHEMA_DONWLOAD_COMPLETE,
    IOT_OTA_EVENT_SCHEMA_DONWLOAD_FAIL,

    IOT_FILE_DOWNLOAD_SCHEDULE = 120,

    // 200+ 为用户事件

} iot_board_event_id_t;
typedef struct 
{
    float temp_current;  
    float humidity_value; 
}iot_board_sensor;

typedef struct 
{
    uint16_t event_id;  
    void* event_payload; 
}iot_board_event_t;


void iot_board_sensor_display(uint16_t event_id, void* payload, uint16_t payload_len);
void iot_board_sensor_get_temhum(iot_board_sensor * iot_sensor);
void get_sensor_value(iot_board_sensor * iot_sensor);

void iot_board_sensor_init(void);
void iot_board_sensor_ui_create(void);
uint8_t iot_board_sensor_get_vbat(void);

#endif